<?php
// ------------------------------------------------------------------------
// |@Author       : Jarmin <edshop@qq.com>
// |@----------------------------------------------------------------------
// |@Date         : 2023-06-24 20:15:25
// |@----------------------------------------------------------------------
// |@LastEditTime : 2023-06-24 20:41:07
// |@----------------------------------------------------------------------
// |@LastEditors  : Jarmin <jarmin@ladmin.cn>
// |@----------------------------------------------------------------------
// |@Description  : 
// |@----------------------------------------------------------------------
// |@FilePath     : Menu.php
// |@----------------------------------------------------------------------
// |@Copyright (c) 2023 http://www.ladmin.cn   All rights reserved. 
// ------------------------------------------------------------------------
namespace app\setting\validate;

use think\Validate;

/**
 * 菜单验证类，用于实现菜单相关的验证操作。
 */
class Menu extends Validate
{
    protected $rule     =   [
        'title'                => 'require|max:30',
        'type'                 => 'require|max:10',
        'name'                 => 'require|max:30|unique:system_menu',
        'ids'                  => 'require|array',
    ];
    
    protected $message  =   [
        'title.require'        => 'menu.title_require',
        'title.max'            => 'menu.title_max',
        'type.require'         => 'menu.type_require',
        'type.max'             => 'menu.type_max',
        'name.require'         => 'menu.name_require',
        'name.max'             => 'menu.name_max',
        'name.unique'          => 'menu.name_unique',
        'ids.require'          => 'menu.ids_require',
        'ids.array'            => 'menu.ids_array',
    ];

    // add 验证场景定义
    public function sceneAdd()
    {
    	return $this->only(['title', 'type', 'name']);
    }

    // edit 验证场景定义
    public function sceneEdit()
    {
    	return $this->only(['title', 'type', 'name']);
    }

    // remove 验证场景定义
    public function sceneDelete()
    {
    	return $this->only(['ids']);
    }
}